﻿using System;
using System.Collections.Generic;
using HAVNet.Core;
using HAVNet.Core.String;


namespace HAVNet.Intros.AST
{
    public class ASTCatchs : List<ASTCatch>
    {
        public override string ToString ()
        {
            return Strings.joinobjs (Environment.NewLine, this);
        }
    }

    public class ASTCatch : ASTNode
    {
        public ASTTypeName  typeName    { get; set; }
        public string       ident       { get; set; }
        public ASTBlock     block       { get; set; }

        public override string ToString ()
        {
            string scatch = "";

            if (typeName == null)
                scatch = "catch ";
            else
                scatch = "catch (" + typeName.ToString() + (string.IsNullOrEmpty(ident) ? "" : " " + ident) + ")";

            return scatch + Environment.NewLine + block.ToString();
        }
    }
}
